home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / MATHS / RLAB / RLAB125.ZIP / !RLaB / LineEditor / !ReadMe next >
Text File  |  1995-02-21  |  21KB  |  459 lines

  1.                         LineEditor Module release 2.66
  2.                         ==============================
  3.  
  4. ** Source, binaries and documentation Copyright (C) Oliver Betts 1994,1995 **
  5.  
  6. This software is provided as is - it has been tested to a reasonable extent,
  7. but probably has a few lurking bugs.  I take no responsibility for any loss
  8. or damage, directly or indirectly caused.
  9.  
  10. UNIX is a trademark of AT&T; 4DOS is a trademark of JP Software Inc.
  11. Incidentally, I highly recommend 4DOS if you have to use DOS.
  12.  
  13. Versions with a letter suffix are test versions and may only be distributed
  14. with express permission from me.  Other versions may be distributed freely
  15. provided all files are supplied intact and that no profit is made.  You may
  16. bundle it with other freeware software provided these distribution
  17. restrictions are met, but please make sure you're supplying the latest
  18. version.  If you want to distribute it in some other way, get in touch.
  19.  
  20. *****************************************************************************
  21.  
  22. This module started out as some modifications to version 2.30 of Richard K.
  23. Lloyd's LineEditor module, to make it work better with TaskWindows
  24. (specifically to use the same *FX4 and *FX 220-228 settings as the Wimp).
  25.  
  26. However, RKL seems not to respond to email or snail mail, and so not having
  27. his permission to release my modified version, I have entirely rewritten the
  28. module.  In doing so I have fixed a number of bugs which were in the original
  29. and added many extra features, some of which were inspired by tcsh (for UNIX)
  30. and 4DOS (for DOS!).
  31.  
  32. I'm still actively working on this program, so watch out for new versions.
  33. Please let me know if you find any bugs or problems (read this file first
  34. though!).  I'll release the source with future versions.
  35.  
  36. Files in this release:
  37.  
  38. !ReadMe    - this file
  39. LineEditor - the module
  40. RebindKeys - obey file to change key bindings
  41. Actions    - a list of the actions which can be bound to keys
  42. DfltKeys   - default key bindings
  43. OllyKeys   - the bindings I use -- provided as an example
  44. Rebinder   - used by RebindKeys -- don't run directly
  45.  
  46. The keys file has a very similar layout to the !Zap keys file.  The
  47. mechanism for rebinding is a bit nasty, and will be improved when I get some
  48. spare time.
  49.  
  50. For a list of the default key bindings, load the LineEditor module and type
  51. "*Help Editor".
  52.  
  53. Random note:  Ctrl-N is now mapped to Next-line (same as cursor down), so to
  54. turn paged scrolling on, you need to type Ctrl-Q Ctrl-N.  Similarly for
  55. some other useful Ctrl-<letter> combinations.  I've bound csL csN csO csT
  56. and csZ to "vanilla" by default, so you can use Ctrl-Shift-N, etc instead.
  57.  
  58. A few comments on use with !Zap (see also !Zap's !Help file):
  59.  
  60. * To use function keys and Control + key you need to type Ctrl-Q first to
  61.   "Quote" the key - otherwise !Zap will process the key.  The cursor keys,
  62.   TAB and PageUp/PageDown are passed through and so don't need quoting.
  63.   !Zap 1.20 will also pass most Ctrl-Letter combinations through, although
  64.   it won't pass through keys that have certain actions bound to them (eg.
  65.   QUOTE).  See the !Zap documentation for a complete list.
  66.  
  67. * COPYing works - activated by the command COPY which is bound to COPY and
  68.   Shift-COPY by default.  From !Zap 1.20, pressing Escape during COPYing will
  69.   stop the copy, but not abort the line.  Press Escape again to abort the
  70.   line.  The LineEditor behaves in the same way outside of TaskWindows.
  71.  
  72. * TaskWindows under RISC OS 2: The TaskWindow module supplied with !Edit on
  73.   RISC OS 2 Application Disc 1 (v 0.03) won't work with !Zap - you need the
  74.   one supplied with the C/Asm DDE (about 0.29) or above.  0.03 only works
  75.   with !Edit 1.00 and not very well.  The RISC OS 3.1 TaskWindow module
  76.   works best of all, but you can't legally get it without having RO 3.1...
  77.  
  78. * With the default keymap supplied with !Zap 1.10 and 1.20, Enter on the
  79.   numeric keypad acts like Ctrl-J in TaskWindows, ie the line isn't stored in
  80.   the history.  You can make it act like Return by altering the appropriate
  81.   line in the keys file from:
  82.    kENTER        &166    RETURN
  83.   to:
  84.    kENTER        &166    CHAR &0D
  85.   which makes Enter behave like Return in TaskWindows, and in other modes.
  86.  
  87. * Due to a bug in !Zap 1.10, Ctrl-Q Ctrl-@ in a TaskWindow gives an `R',
  88.   rather than setting the mark.  A work around is to use Ctrl-Q Ctrl-SPACE
  89.   instead in TaskWindows.  This is fixed in 1.20.
  90.  
  91. Use with !Edit/!SrcEdit:
  92.  
  93. * !Edit/!SrcEdit TaskWindows don't "understand" the codes to move the cursor
  94.   left and right (&08 and &09) so things don't work terribly well.  Also, the
  95.   code for a beep (&07) is ignored, so failing filename completions don't
  96.   beep.
  97.  
  98. * My version and RKL's seem to work equally well/badly (simple recall and
  99.   filename completion work okay).
  100.  
  101. * I don't think it's possible to work around not having VDU 8 - get !Zap if
  102.   you want to use TaskWindows much - it's much faster too!
  103.  
  104. Use with RISC OS 2:
  105.  
  106. * I've added code to versions 2.34 and above to read the task handles of
  107.   TaskWindows under RISC OS 2, so local history buffers should now work.
  108.  
  109. * The TaskWindow modules supplied with RISC OS 2 and the Acorn C DDE (0.03
  110.   and 0.29 anyway) have a problem - if the LineEditor is loaded, closing a
  111.   TaskWindow doesn't release the memory allocated to the task.  This would
  112.   seem to be a TaskWindow bug [it occurs if you soft-load 0.03 or 0.29 with
  113.   RISC OS 3.1, and with RKL's version].  My best advice (other than to get
  114.   RISC OS 3.1) is to reduce the next slot before starting a TaskWindow and
  115.   not to close task windows that you might want again.
  116.  
  117. * There's a problem with the cursor keys producing symbols rather than being
  118.   interpreted as cursor keys with some setups when using TaskWindow 0.29.
  119.  
  120. Comments and suggestions are greatly encouraged - email will get a reply (if
  121. I can get through), snail mail will eventually, but don't hold your breath. 
  122. If email bounces, I read the usenet group comp.sys.acorn regularly.  Please
  123. try to give as much detail as possible in bug-reports - steps to demonstrate
  124. the bug from loading in the module are very helpful indeed.
  125.  
  126. Thanks to Andy Hayward, David Moore and Dom Symes for testing and comments.
  127. Also to Clive Jones for suggesting how to find the current task's handle
  128. under RISC OS 2 (though his idea didn't work ;) ).  Also, thanks to everyone
  129. who's reported bugs and problems, particularly Ian Palmer and Nick Craig-Wood
  130. who've been especially diligent.  And to Ben Summers for supplying some
  131. (slightly buggy) code for creating a dynamic area and maintaining a heap in
  132. it, and to OSLib's headers for telling me how to delete a dynamic area once
  133. I've got one.
  134.  
  135. You can obtain the latest version by anonymous ftp from ftp.mantis.co.uk
  136. (193.129.10.1) in the directory /pub/users/olly.  The file is le???.arc
  137. decodable using !SparkPlug or similar.
  138.  
  139. If you can't ftp, send me an email with "req-lineed" in the subject line, and
  140. my mailer will automagically uuencode and mail you the latest version.
  141.  
  142. Olly Betts, 1995.02.21
  143.  
  144. Internet email:         olly@mantis.co.uk
  145.  
  146. Indirected snail mail:  Olly Betts,
  147.                         24 Morgans Road,
  148.                         Hertford,
  149.                         Herts,
  150.                         SG13 8BS,
  151.                         UK
  152.  
  153.  
  154. Improvements/bugfixes over RKL's 2.30:
  155. ======================================
  156.  
  157. More TaskWindow compatible:
  158. ---------------------------
  159.  
  160. Changed to use same *FX4 and *FX 220-228 settings as Wimp, so using the
  161. line editor in a TaskWindow doesn't screw up the cursor keys.
  162.  
  163. More values are stored in registers or blocks rather than absolute locations,
  164. which greatly improves behaviour with multiple TaskWindows.
  165.  
  166. Each TaskWindow now has a separate currently-recalled-line pointer.  If
  167. Global history is on, when lines are deleted (by Shift-Insert, or when the
  168. history buffer gets full), the pointers for each TaskWindow are adjusted
  169. appropriately.
  170.  
  171. Function keys work separately in each TaskWindow.
  172.  
  173. You can't *RMKill the LineEditor module while a line is being entered.
  174.  
  175. Miscellaneous bugs fixed:
  176. -------------------------
  177.  
  178. Ctrl-H performs backspace (RKL's interprets it as Ctrl-Delete and erases
  179. the entire contents of the history buffer!)
  180.  
  181. Backspace in overtype mode didn't delete characters on the screen.
  182.  
  183. RKL's gave incorrect underline cursor in non-BBC gap modes (eg MODE 17).
  184.  
  185. Escape now moves cursor to end of line before exiting.
  186.  
  187. You can now enter all top-bit-set characters; Eg With RKL's version, you
  188. can't enter LOAD"Ý" (to type "Ý" hold down ALT and type 221 on the numeric
  189. keypad, then release ALT - RKL's reads it as Shift-Insert).
  190.  
  191. Filename completion code now copes with long leafnames (RKL's would break
  192. for leafnames >11 characters eg AUTOEXEC/BAT is 12).
  193.  
  194. RKL's used CMOS locations 37 and 38, but his !Trash also uses bits 0-2 of
  195. location 38 - I use location 37 and bits 3-7 of location 38.
  196.  
  197. R12 wasn't being passed to readlinev - RKL had just hacked around this...
  198.  
  199. V flag is explicitly cleared on errorless exit from ReadLineV routine, as
  200. OS_CallAVector doesn't clear V on entry (RISC OS 2 PRMs, vol I, page 30).
  201.  
  202. Module initialisation code would call OS_GenerateError upon failure - it
  203. should return with V set and R0 -> error block (RO3 PRMs, page 1-204).
  204.  
  205. Other changes which I view as improvements:
  206. -------------------------------------------
  207.  
  208. For RISC OS 3.5, it will now create its own dynamic area for workspace,
  209. rather than using the RMA.  This should help to reduce RMA fragmentation,
  210. especially if local history buffers are used.
  211.  
  212. You can now have separate history buffers for each TaskWindow (controlled by
  213. bit 0 of *Configure EdFlags).  Ctrl-Delete wipes *current* history buffer;
  214. *EraseHistory and Shift-Ctrl-Delete wipe *all* history buffers.  When in
  215. local buffer mode, *Recall and *EdStatus put a '*' by the last used buffer.
  216. If the command was typed in using OS_ReadLine, this will be the "current"
  217. buffer, but results may be less meaningful if the command is executed by a
  218. program.
  219.  
  220. Added PageUp/PageDown to scroll through lines with start matching entered
  221. line (also on shift-cursor-up/down) [like Instigator and cursor up/down in
  222. 4DOS].
  223.  
  224. Added Emacs-like bindings [mostly from tcsh]:
  225. Duplicating existing keys:
  226.  ^A ^E start/end of line ^B ^F cursor left/right ^N ^P next/prev line
  227.  ^D delete right
  228. New actions:
  229.  ^Q quote next key, ^T transpose, ^K delete to end of line, ^@ place mark,
  230.  ^X exchange cursor with mark (Emacs ^X ^X), ^W delete region,
  231.  Shift-^D delete to end of word, ^Y yank back last text deleted with ^K, ^W,
  232.  or Shift-^D
  233.  
  234. Added another style of filename completion (like 4DOS).  Shift-Tab completes
  235. fully on first match, then Shift-Tab and Ctrl-Shift-Tab step through other
  236. matches.
  237.  
  238. Removed nasty hacky "Supervisor awareness" as it didn't work for RO 3.x or
  239. at ShellCLI prompt (f12 from desktop). Replaced with better system (for
  240. Acc.Fred[Tab] it looks first for "Acc.Fred*"; if that fails it then looks
  241. for "Fred*" [on the assumption that Acc. is an abbreviated *-command]).
  242.  
  243. There is no longer a limit on the number of lines in the history buffer,
  244. only on the size of the buffer.
  245.  
  246. You can specify a minimum length of line to record in the history (currently
  247. you set bits 4-7 of the flags byte to one less than this length, so 4 records
  248. all lines of 5 characters or more).
  249.  
  250. Doesn't display copyright message on start-up and reset.
  251.  
  252. Syntax messages added for commands.
  253.  
  254. Code doesn't bother trying to change cursor shape in TaskWindows (as VDU
  255. sequences are ignored and only slow things up more).
  256.  
  257. The code is "lazier" about inserting and deleting characters during filename
  258. completion - this gives a slight speed increase in TaskWindows.
  259.  
  260. My completion code doesn't insert `delete' characters into the keyboard
  261. buffer, which might have caused problems if you pressed Shift or Ctrl at
  262. just the wrong moment.
  263.  
  264. Next/previous word treat '(' and ')' as word breaks (same as !Zap 1.10).
  265.  
  266. Module help messages compacted using OS dictionary.
  267.  
  268. Ctrl-L & HOME now redraw current line (bit like tcsh).
  269.  
  270. ^J still behaves like RETURN but doesn't store line in history.
  271.  
  272. Doesn't do *Unset LineEditor$Dir (was done incorrectly for *EraseHistory for
  273. example).
  274.  
  275. Buffers for filename completion code are only allocated when they're needed.
  276.  
  277. No swi-padding code as it is *not* needed (slightly faster and smaller).
  278.  
  279. Added option to assemble with less verbose help text.
  280.  
  281. You can configure completion to add a '.' when completing a directory name,
  282. (a bit like tcsh adds a '/').  However "ls foo/" works and "cat foo."
  283. doesn't, so this is configurable (set bit 1 of EdFlags to turn it on).  It
  284. also is not currently done for 4DOS style completion, as the dot would stop
  285. the stepping through the current directory - I might recode to fix this
  286. later.
  287.  
  288. You can configure overtype mode to be on by default if you prefer (though
  289. why you would is beyond me - still, DOS 6 does it...)
  290.  
  291.  
  292. Shortfalls compared to RKL's version:
  293. =====================================
  294.  
  295. Changes to *Configure EdSize don't affect existing history buffer(s), but are
  296. used for new buffers.  I'm not sure if this is actually a shortfall or a
  297. useful feature - may be fixed.
  298.  
  299. No wimp frontend (or is that an improvement?) - seriously, let me know if
  300. you think a Wimp frontend is needed - I might write one if it's wanted...
  301.  
  302. Hasn't been tested with Arthur (the Archimedes OS before RISC OS) - the help
  303. text is compacted but otherwise I think all the new OS calls used fail-safe.
  304. Do let me know if you try it...
  305.  
  306. Minor "feature" - *FX216,0 no longer stops current function key expansion
  307. during OS_ReadLine, but this is no big deal really - it could be solved by
  308. intercepting OS_Byte, but I can't see much point.
  309.  
  310.  
  311. Possible future additional features:
  312. ====================================
  313.  
  314. Getting there:
  315.  Add completion of *-commands (I have a prototype working)
  316.  Improve key redefining stuff
  317.  
  318. Improve this documentation!
  319.  
  320. Some actions can be pretty slow (eg type a very long line with no spaces in
  321. a taskwindow, go to the start and delete word (Ctrl-Shift-D).  Then go and
  322. put the kettle on if you have an ARM 2.  This could be improved if the code
  323. was lazier and redrew only the finished result - although as it stands it
  324. does look quite slick on the command line with an ARM 3 or above.
  325.  
  326. Doesn't work wonderfully in VDU5 mode [neither does RKL's] - maybe fix.
  327.  
  328. Maybe add Ctrl-Page-Up/Down to scroll case sensitive.
  329.  
  330. If we allow the size of existing buffers to change, we should preserve as
  331. much of the history as will fit in new size buffer.
  332.  
  333. As with RKL's, you can recall lines which have characters in which are
  334. outside the range specified by R2 and R3 on entry to OS_ReadLine - the only
  335. solutions I can see are to strip them out (not wonderful) or to only allow
  336. recall if all chars in the range &20-&FF are allowed (this applies to
  337. ShellCLI, BASIC, and GOS (TaskWindows)).  The problem also applies to
  338. filename completion.  Ideas on this one are especially welcome.
  339.  
  340. Other (please specify): ....................................................
  341.  
  342. Revision History:
  343. =================
  344. 2.66 Now creates dynamic area for workspace under RISC OS 3.5
  345.  
  346. 2.65 [Bundled in !Zap 1.20 release]
  347.      Improved key decoding code so that ctrl-C in taskwindows copies numbers
  348.       okay
  349.      Unbound keys default to vanilla not ignore
  350.      Previously undocumented feature:  vanilla treats Ctrl-J as action return
  351.       so it won't enter lines into the history -- this is useful for function
  352.       keys where you probably don't want the commands executed put in the
  353.       history (Eg. *Set Key$4 <0><&94>SYS"Wimp_CommandWindow",-1|JQUIT|J
  354.       makes scF4 quit the BASIC Editor and return to the desktop)
  355.      sc2 (c@ on except on Risc PC) now bound to setmark
  356.      Now deals with flag bits in bits 30 and 31 of R0 on entry to
  357.       OS_ReadLine.  Bit 30 is set for password entry and if set, the
  358.       OS OS_ReadLine is used.  Bit 31 set means echo only those characters
  359.       which enter the buffer and is ignored currently
  360.      vanilla now handles Ctrl-H and Delete
  361.  
  362. 2.64 sReturn, cReturn, scReturn and scJ are now mapped
  363.      If you're copying, Escape now cancels copying mode and leaves you
  364.       editting the line.  Press Escape again to abandon the line.  This
  365.       currently doesn't work with copying in !Zap TaskWindows, since !Zap
  366.       handles the copying itself.  The next release of !Zap will behave in 
  367.       the same way.  In the meantime, you can either use ^B and ^F during
  368.       copying, or bind a spare key to uncopy
  369.      You can bind uncopy to keys to stop copying (note that binding it to
  370.       COPY or the cursor keys won't work, as the OS/!Zap takes control of
  371.       them during copying).  The copy action now toggles, but this doesn't
  372.       work if bound to the COPY key for the same reason
  373.      If keystrokes are actually coming from an OS function key expansion,
  374.       now treat them as OS_ReadLine would, so you can program this:
  375.       *KEY 4 <0><&94>SYS"Wimp_CommandWindow",-1|MQUIT|M
  376.       and then use scF4 to return from the BASIC Editor to the desktop
  377.  
  378. 2.63 Shift-SPACE now produces a SPACE in the Default map (and Olly's)
  379.      Keypad /*-+. and Enter now work in the Default map (and Olly's)
  380.      Fixed bug in code which works out !Zap key numbers - discovered via
  381.       dropped characters in combination with Brian Brunswick's Bits module
  382.      Fixed non-freeing of a small amount of RMA if allocation of a new buffer
  383.       fails part-way through
  384.      Fixed problem of "LineEditor in use" when it had never been used
  385.  
  386. 2.62 With global history, if you hadn't used a non-TaskWindow command line,
  387.       then the history was lost if all TaskWindows were closed - fixed
  388.  
  389. 2.61 Fixed bug with reading value of EdFlags
  390.      Fixed off-by-one error in interpretation of minimum line length to store
  391.  
  392. 2.60 Cursor probably didn't get redefined for RISC OS 2 - should be now
  393.      Fixed bug which recalled junk on pressing cursor-up on a non-empty
  394.       line when history was empty
  395.      Streamlined service call handler for "nothing of interest" case
  396.      Should cope better if any SWI OS_Write* returns an error (and hence
  397.       corrupts R0) - eg if *Spool-ing output and the disk becomes full
  398.      All case-insensitive matching code rewritten to be smaller and faster
  399.      Next/previous word now works just like in Zap 1.10 - ie ' ', '(' and ')'
  400.       are treated as word breaks
  401.      Now allocates leafname buffers for filename completion on-the-fly, so
  402.       we can now cope with arbitrarily long leafnames. Tested with Jason
  403.       Tribbeck's LongFilenames module (version 0.08)
  404.      Added ^Y to yank back text deleted with ^K, ^W (like emacs)
  405.      Filename completion now works properly in overtype mode
  406.      *Help Editor output tweaked to fit better on 80x32 screen
  407.      Ctrl-Shift-D deletes to end of word (Emacs Meta-D)
  408.      Keypresses now decoded using !Zap key codes and a 512 byte table to
  409.       enable easy re-mapping
  410.      Compacted help messages using own dictionary
  411.      You can specify a minimum length of line to record in the history -
  412.       currently you set bits 4-7 of EdFlags to one less (eg 4 to store lines
  413.       of 5 chars or more), so 1 <= min. length <= 16
  414.      Doesn't output VDU sequences to change cursor on start-up now (stops
  415.       empty window appearing when LineEditor module run from Filer)
  416.      Ctrl-Down on typed line with empty history gave garbage - fixed
  417.      Delete word can be yanked back
  418.  
  419. 2.53 Path buffer for filename completion now allocated on the fly
  420.  
  421. 2.52 Routine `free' now returns R0=0
  422.      Explicitly clear V on errorless exit from ReadLineV (bug-fix over RKL)
  423.      Fettled help messages and compacted a little more
  424.      R12 is mostly derefenced on entry (smaller and faster)
  425.      OS_GBPB buffer allocated on the fly
  426.      Print padded decimal routine uses 12 bytes of stack for workspace
  427.  
  428. 2.51 Dom suggested adding a '.' when filename completion completed to a
  429.       directory - controlled by bit 1 of EdFlags
  430.      Set bit 2 of EdFlags to turn overtype mode on by default
  431.  
  432. 2.50 [Bundled in !Zap 1.10 release]
  433.      Pressing Tab/^I on an empty line incorrectly moved the cursor left one
  434.       character if a completion occured
  435.      Deleting left at the end of a recalled line didn't set the modified flag
  436.      With empty history, typing something and pressing PageUp recalled crap
  437.      Added 4DOS style filename completion:  Shift-Tab completes fully, then
  438.       steps thru' completions - Shift-Ctrl-Tab steps backwards
  439.      Shift-Copy does the same as Copy (to match !Zap defaults)
  440.      Updated and tidied output from *Help Editor
  441.  
  442. 2.40 Tidied up a little for release with !Zap 1.10 ('cept it's been delayed)
  443.  
  444. 2.35 TaskWindow tracking workspace if now freed on soft-reset
  445.      If a claim for RMA fails, a beep is emitted and something sensible done
  446.       (start-up gives an error, a function key is ignored, starting a new
  447.       TaskWindow reverts to the default OS_ReadLine routine)
  448.      Fixed minor bug in filename expansion code (introduced in 2.34)
  449.      PageUp and PageDown now don't insert start line into the history
  450.  
  451. 2.34 Fixed minor bug in filename completion code
  452.      Added code to find task handle for RISC OS 2 (easier than I thought)
  453.      Now marks "current" buffer with a '*' in *Recall and *EdStatus if
  454.       local history is in operation
  455.      Recoded filename completion to enter characters directly, rather than
  456.       via keyboard buffer
  457.  
  458. 2.33 First beta release
  459.